<?php
/**
 * Created by PhpStorm.
 * User: Tsang
 * Date: 2017/9/24 16:20
 *
 */

namespace app\api\model;

use think\Model;

class Income extends Model
{

    /**
     * 获取所有
     * @param $original
     * @return mixed
     */
    public function getAll($where='')
    {
        $team = $this->where($where)->select();
        return $team;
    }

    /**
     * 获取推荐人佣金收入记录
     * @param $original
     * @return mixed
     */
    public function getSr($where='')
    {
        $task_tc = db('proportion')->where('tc_type',2)->value('tc_price');//一级任务提成
        $team = $this->where($where)->where('status',2)->select();
        foreach ($team as $key => $value) {
            $team[$key]['money_tc'] = round($value['money'] * $task_tc / 100,2);
            $team[$key]['created_at'] = date('Y-m-d H:i:s',$value['created_at']);
            if (!empty($value['update_at'])){
                $team[$key]['update_at'] = date('Y-m-d H:i:s',$value['update_at']);
            }
        }
        return $team;
    }
}